<?php
$filename = $_FILES['uploadedfile']['name'];
$savePath = "user_img/".$filename;
$saveSmallName = "user_img/sml".$filename;

if(is_uploaded_file($_FILES['uploadedfile']['tmp_name'])){
	if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$savePath)){
		$ext = strtolower(get_ext($savePath));
		$width = $height = 60;
		list($oriWidth,$oriHeight) = getimagesize($savePath);
		if($ext == "jpg"){
			$im = imagecreatefromjpeg($savePath);
			$target = imagecreatetruecolor($width,$height);
	/*		imagealphablending($target, false);
        	imagecolortransparent($target, imagecolorallocatealpha($target, 0, 0, 0,0));*/
			imagecopyresampled($target,$im,0,0,0,0,$width,$height,$oriWidth,$oriHeight);
			imagejpeg($target,$saveSmallName);
		}
		else if($ext == "png"){
			$im = imagecreatefrompng($savePath);
			$target = imagecreatetruecolor($width,$height);
		//	imagesavealpha($target,true);
		/*	imagealphablending($target, false);
        	imagecolortransparent($target, imagecolorallocatealpha($target, 0, 0, 0,0));*/
			imagecopyresampled($target,$im,0,0,0,0,$width,$height,$oriWidth,$oriHeight);			
			imagepng($target,$saveSmallName);
		}		
		echo "100";
	}
	else
		echo "101";
}
else 
	echo "101";

function get_ext($filename){
	return substr(strrchr($filename,'.'),1);
}
?>